﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
using Wpf.CommonTools.NumberExtension;

namespace Convertor
{
    class LogListConverter : IMultiValueConverter
    {
        //#region IValueConverter 成员

        //public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        //{
        //    int page = value.ToInt32(1);
        //    int pageSize = parameter.ToInt32(10);
        //    var list = Config.LogList.Skip(page * pageSize).Take(pageSize);
        //    return list;
        //}

        //public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        //{
        //    throw new NotImplementedException();
        //}

        //#endregion

        #region IMultiValueConverter 成员

        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (DesignerProperties.GetIsInDesignMode(new DependencyObject()))
            {
                return null;
            }
            else
            {
                ObservableCollection<LogContent> c = values[0] as ObservableCollection<LogContent>;
                
                int page = values[1].ToInt32(1);
                int pageSize = values[2].ToInt32(10);
                var list = c.Skip(page * pageSize).Take(pageSize);
                return list;
            }
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
